package system.student.entity.signin;

import java.time.LocalDateTime;

public enum SignInState {
    Pending{
        public SignInState next(SignInTask signInTask) {
            LocalDateTime now = LocalDateTime.now();
            if (now.isBefore(signInTask.getStartTime())) {
                return Pending;
            } else if (now.isBefore(signInTask.getEndTime())) {
                return Ongoing;
            } else {
                return Closed;
            }
        }
    },
    Ongoing{
        public SignInState next(SignInTask signInTask) {
            if (LocalDateTime.now().isAfter(signInTask.getEndTime())){
                return SignInState.Closed;
            }
            return this;
        }
    },
    Closed{
        public SignInState next(SignInTask signInTask) {
            return SignInState.Closed;
        }
    };
    public abstract SignInState next(SignInTask signInTask);
}
